<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>用户信息列表</title>

<script type="text/javascript" src='<s:url value="/js/jquery-1.9.1.min.js" />'></script>

<script type="text/javascript">
	
	$(function(){
		$(".delete").click(function(){
			var nickName = $(this).next(":hidden").val();
			var flag = confirm("确认要删除" + nickName + "的信息吗？");
			if(flag){
				var $tr = $(this).parent().parent();
				var url = this.href;
				var args = {"time" : new Date()}; 
				$.post(url, args , function(data){
					if(data == "1"){
						alert("删除成功!");
						$tr.remove();
					}else{
						alert("删除失败!");
					}
				});
			}	
			
			return false;
		});
	});

</script>

</head>
<body>
		<s:if test="#request.user == null || #request.user.size() == 0 ">
			没有任何用户信息！
		</s:if>
		<s:else>
			<table border="1" cellpadding="10" cellspacing="0" width="1000px">
				<tr>
					<td>ID</td>
					<td>昵称</td>
					<td>邮箱</td>
					<td>注册时间</td>
					<td>角色</td>
					<td>编辑</td>					
					<td>删除</td>
				</tr>
				<s:iterator value="#request.user">
					<tr>
						<td>${id}</td>
						<td>${nickName}</td>
						<td>${email}</td>
						<td>
							<s:date name="regDate" format="yyyy-MM-dd hh:mm:ss"/>
						</td>
						<td>${position.positionName}</td>
						<td>
							<a href="ssh-edit?id=${id }">编辑</a>
						</td>
						<td>
							<a href="ssh-delete?id=${id }" class="delete">删除</a>
							<input type="hidden" value="${nickName }">
						</td>
					</tr>
				</s:iterator>
			</table>
		</s:else>
</body>
</html>